Skip to content

feat: Add DON ID type validation and Rev Orgs service (CUSS-396, CUSS-397)#207

Merged
mgmonteleone merged 5 commits intomainfrom
feature/cuss-396-397-don-id-validation-rev-orgs
Apr 14, 2026
Merged

feat: Add DON ID type validation and Rev Orgs service (CUSS-396, CUSS-397)#207
mgmonteleone merged 5 commits intomainfrom
feature/cuss-396-397-don-id-validation-rev-orgs

Conversation

@mgmonteleone
Copy link
Copy Markdown
Owner

Overview

This PR implements two related enhancements to improve the DevRev MCP tools and SDK:

  1. CUSS-396: DON ID type validation with helpful error messages
  2. CUSS-397: Rev Orgs (revenue organizations) service

Problem

Users were getting generic "Validation error: Bad Request" when passing the wrong type of DON ID to MCP tools (e.g., passing a rev_org ID revo/... to devrev_accounts_get which expects an account ID account/...). Additionally, there was no way to look up rev_orgs directly.

What Changed

CUSS-396: DON ID Type Validation

New file: src/devrev_mcp/utils/don_id.py

  • parse_don_type(don_id) — extracts the object type segment from a DON ID
  • validate_don_id(don_id, expected_types, tool_name) — soft-validates DON IDs with clear error messages
  • DON_TYPE_MAP — maps DON type segments to human-friendly names
  • TOOL_SUGGESTIONS — maps DON types to the correct MCP tool for helpful suggestions

Modified: 14 MCP tool files — added validate_don_id() calls to all _get, _update, _delete operations:

  • accounts.py, articles.py, conversations.py, engagements.py, groups.py, incidents.py, links.py, parts.py, question_answers.py, slas.py, tags.py, timeline.py, users.py, works.py

Example error message:

The provided ID 'don:identity:dvrv-us-1:devo/11Ca9baGrM:revo/CHjPMe8K' appears to be a rev_org ID,
but devrev_accounts_get expects an account ID. Try using devrev_rev_orgs_get instead.

CUSS-397: Rev Orgs Service

New files:

  • src/devrev/models/rev_orgs.py — Pydantic v2 models (RevOrg, RevOrgSummary, request/response models)
  • src/devrev/services/rev_orgs.py — Sync RevOrgsService and async AsyncRevOrgsService
  • src/devrev_mcp/tools/rev_orgs.py — MCP tools (list, get, create, update, delete)

Modified:

  • src/devrev/client.py — Added rev_orgs property to both clients
  • src/devrev/models/__init__.py — Exported rev_orgs models
  • src/devrev/services/__init__.py — Exported rev_orgs services
  • src/devrev_mcp/server.py — Registered rev_orgs tools

Testing

  • 22 new tests for DON ID validation (tests/unit/test_don_id_validation.py)
  • 19 new tests for Rev Orgs models and services (tests/unit/test_rev_orgs.py)
  • All 1091 tests pass — zero regressions
  • Ruff linting clean

Deployment Notes

  • No breaking changes — validation is soft (non-DON IDs pass through silently)
  • New MCP tools are automatically registered
  • Destructive rev_orgs tools (create/update/delete) are behind the enable_destructive_tools config flag

Related Issues

  • Implements: CUSS-396
  • Implements: CUSS-397

Pull Request opened by Augment Code with guidance from the PR author

CUSS-396: Add DON ID type validation with helpful error messages
- Create src/devrev_mcp/utils/don_id.py with parse_don_type and validate_don_id
- Integrate validation into all 14 MCP tool files (_get, _update, _delete ops)
- Provides clear error messages when wrong ID type is used (e.g. rev_org ID
  passed to accounts_get) with tool suggestions

CUSS-397: Add Rev Orgs (revenue organizations) service
- Create Rev Orgs Pydantic v2 models (RevOrg, RevOrgSummary, request/response)
- Implement sync RevOrgsService and async AsyncRevOrgsService
- Register services in DevRevClient and AsyncDevRevClient
- Create MCP tools: list, get, create, update, delete
- 41 new unit tests (22 for DON ID validation, 19 for Rev Orgs)
- All 1091 tests pass
@mgmonteleone mgmonteleone marked this pull request as ready for review April 13, 2026 23:36
@mgmonteleone mgmonteleone added the agent-reviewing PR is being processed by the agent label Apr 13, 2026
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 13, 2026

🤖 Augment PR Summary

Summary: This PR improves DevRev MCP tooling ergonomics by validating DON ID object types up-front and adds first-class support for Rev Orgs (revenue organizations) in both the SDK and MCP layer.

Changes:

  • Added devrev_mcp.utils.don_id with parse_don_type() and validate_don_id() to detect wrong-ID-type usage and produce actionable messages.
  • Wired validate_don_id() into many MCP tools’ get/update/delete paths (plus account merge) to catch mismatched DON types earlier than the API.
  • Introduced new Pydantic v2 models for Rev Orgs in src/devrev/models/rev_orgs.py.
  • Added new sync/async SDK services in src/devrev/services/rev_orgs.py and exported them via devrev.services.
  • Extended both clients to expose client.rev_orgs / async_client.rev_orgs.
  • Added MCP tool implementations for rev orgs (list/get + destructive create/update/delete behind enable_destructive_tools) and registered them in the MCP server.
  • Added unit tests covering DON ID validation and rev org models/services.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Args:
id: The rev org ID.
"""
validate_don_id(id, "revo", "devrev_rev_orgs_get")
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/devrev_mcp/tools/rev_orgs.py:68 validate_don_id() can raise ValueError, but this call happens outside the try that converts errors into RuntimeError, so users may see an unformatted exception instead of the usual MCP-friendly message.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6c39d01. Changed validate_don_id() to raise RuntimeError instead of ValueError, so the exception is now caught by the existing except ... RuntimeError blocks in all MCP tool handlers. This fixes the issue across all 40+ call sites without needing to modify any individual tool file.

Comment thread tests/unit/test_rev_orgs.py Outdated
def sample_rev_org_data() -> dict[str, Any]:
"""Minimal Rev Org data matching the API response shape."""
return {
"id": "don:core:dvrv-us-1:devo/1:revorgs/123",
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/unit/test_rev_orgs.py:50 The fixture uses a rev org DON type segment revorgs, but the new validation/docs elsewhere use revo for rev org IDs; this mismatch could mask a real validation bug if one of these segments is incorrect.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6c39d01. Replaced all revorgs/ with revo/ in the test fixtures to match the actual DevRev DON type segment used in production IDs and in the validation logic.

Matthew Monteleone added 2 commits April 13, 2026 17:13
…ype in tests (#207)

- Changed validate_don_id to raise RuntimeError instead of ValueError so
  exceptions are caught by MCP tool handlers and shown as friendly messages
- Fixed test fixture DON IDs from 'revorgs/' to 'revo/' to match actual
  DevRev DON type segments
- Bump softprops/action-gh-release from v2 to v3 (#208)
- Bump actions/deploy-pages from v4 to v5 (#209)
- Bump actions/github-script from v8 to v9 (#210)
- Bump cryptography from 46.0.5 to 46.0.7 - security fix CVE-2026-39892, CVE-2026-34073 (#206)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewing PR is being processed by the agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant